package com.tianlh.service.design_pattern.Observable;

/**
 *
 * @author wb-tianlihui
 * @date 2017/12/19
 */
public class TestObserver {

    public static void main(String[] args) throws InterruptedException {
        Thread th = new Thread(new Runnable() {
            @Override
            public void run() {
                Thread th2 = new Thread(new Runnable() {
                    @Override
                    public void run() {
                        while(true){
                            try {
                                System.out.println("haha1");
                                Thread.sleep(2000);
                            } catch (InterruptedException e) {
                                e.printStackTrace();
                            }
                        }
                    }
                },"haha1");
                th2.start();

                while(true){
                    try {
                        System.out.println("haha");
                        Thread.sleep(2000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }, "haha");
        th.start();
        System.out.println("main 跑完了");
        Thread.sleep(20000);
    }
}
